package com.suse.service.cos.controller;

import com.suse.common.config.response.R;
import com.suse.service.cos.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@Api(tags = "文件上传接口")
@RestController
@RequestMapping("/cos/file")
@CrossOrigin
public class FileController {

    @Resource
    private FileService fileService;

    @ApiOperation(value = "上传文件")
    @PostMapping("/upload")
    public R uploadFile(MultipartFile file) {
        return fileService.uploadFile(file);
    }

    @ApiOperation(value = "删除文件")
    @DeleteMapping("/remove")
    public R removeFile(@RequestBody String url) {
        return fileService.removeFile(url);
    }

}
